<template>
  <el-form :model="fromData" label-width="100px" :show-message="false" ref="fromData">
    <el-timeline :reverse="false">
      <el-timeline-item
        v-for="(activity, index) in activities"
        :key="index"
        :color="activity.color"
        :timestamp="activity.auditTime">
        {{activity.auditBy}}： {{activity.statusValue}}
      </el-timeline-item>
    </el-timeline>

    <el-form-item label="处理状态:">
      <el-select v-model="fromData.auditStatus">
        <el-option
          v-for="item in auditStatusOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="处理备注:">
      <el-input type="textarea" v-model="fromData.remark" clearable show-word-limit :autosize="{ minRows: 4, maxRows: 6 }" placeholder="备注"></el-input>
    </el-form-item>
    <el-row>
      <el-col :span="24" align="center">
        <el-button type="primary" @click="onSubmit">确认</el-button>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
  import { auditStatus, auditRecords } from "@/api/after-sale/storehouseManage/outOfStockManage";
  import { parseTimeToYMDHMS } from "@/utils";
  export default {
    name: 'DialogDataForm',
    props: {
      id: Number,
    },
    data() {
      return {
        fromData: {
          auditStatus: 3,
          remark: '',
        },
        auditStatusOptions: [
          { value: 3, label: '通过' },
          { value: 4, label: '拒绝' },
        ],
        activities: []
      }
    },
    async created() {
      this.fromData.id = this.id;
      const {success, data} = await auditRecords(this.id);
      if (success) {
        data.forEach(e => {
          e.auditTime = parseTimeToYMDHMS(e.auditTime);
          e.color = '#0bbd87';
        });
        this.activities = data;
        console.log(data);
      }
    },
    methods: {
      onSubmit() {
        auditStatus(this.fromData).then(response => {
          if (response.success) {
            this.$message.success('操作成功');
          }
        })
      },
    },
  }
</script>
<style lang="scss" scoped>
</style>

